﻿var id = null
var personnelname = null;
var age = null;
var gender = null;
var phone = null;
var address = null;
var position = null;
var saveBtn = null;
var backBtn = null;

$(function(){
    id = $("#id");
    personnelname = $("#personnelname");
    age = $("#age");
    gender = $("#gender");
    phone = $("#phone");
    address = $("#address");
    position = $("#position");
    saveBtn = $("#save");
    backBtn = $("#back");

    personnelname.next().html("*");
    age.next().html("*");
    // gender.next().html("*")
    personnelname.on("focus",function(){
        validateTip(personnelname.next(),{"color":"#666666"},"* 姓名不能为空",false);
    }).on("blur",function(){
        if(personnelname.val() != null){
            validateTip(personnelname.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(personnelname.next(),{"color":"red"},imgNo+" 账户金额有误",false);
        }
    });
    age.on("focus",function(){
        validateTip(age.next(),{"color":"#666666"},"年龄不能为空",false);
    }).on("blur",function(){
        if(age.val() != null){
            validateTip(age.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(age.next(),{"color":"red"},imgNo+" 年龄不能为空",false);
        }
    });

    saveBtn.on("click",function(){
        personnelname.blur();
        age.blur();
        if(personnelname.attr("validateStatus") == "true"
            && age.attr("validateStatus") == "true"){
            if(confirm("确定提交数据吗？")){
                $("#staffForm").submit();
            }
        }
    });

    backBtn.on("click",function(){
        //alert("modify: "+referer);
        if(referer != undefined
            && null != referer
            && "" != referer
            && "null" != referer
            && referer.length > 4){
            window.location.href = referer;
        }else{
            history.back(-1);
        }
    });
});